Skip to content

Enhancement/browser tools#147

Merged
MarcSkovMadsen merged 6 commits into
mainfrom
enhancement/browser-tools
Feb 19, 2026
Merged

Enhancement/browser tools#147
MarcSkovMadsen merged 6 commits into
mainfrom
enhancement/browser-tools

Conversation

@MarcSkovMadsen

Copy link
Copy Markdown
Owner

Summary

  • Rename panel_take_screenshot to panel_inspect_app and extend it to capture both screenshots and browser console logs in a single call, making it easy to debug JavaScript errors in Panel apps (especially custom components)
  • Add panel-live and panel-reactflow as built-in documentation repositories in config.yaml
  • Update docs/explanation/tools.md to document the new tool name, parameters, and use cases

Changes

panel_inspect_app (renamed from panel_take_screenshot)

The tool now returns a list[TextContent | ImageContent] instead of a single ImageContent, with three new parameters:

Parameter Type Default Description
screenshot bool True Whether to capture a screenshot
console_logs bool True Whether to capture browser console logs
log_level str | None None Filter logs by level ("error", "warning", "log", etc.)

All existing parameters (url, width, height, full_page, delay, save_screenshot) are preserved unchanged.

Raises ValueError if both screenshot=False and console_logs=False.

New built-in doc repositories

  • panel-live (panel-extensions/panel-live)
  • panel-reactflow (panel-extensions/panel-reactflow)

Files changed

  • src/holoviz_mcp/panel_mcp/server.py — Rename tool, add console log capture via Playwright page.on("console"), return mixed content list
  • src/holoviz_mcp/panel_mcp/models.py — Add ConsoleLogEntry Pydantic model
  • src/holoviz_mcp/config/config.yaml — Add panel-live and panel-reactflow repositories
  • src/holoviz_mcp/config/models.py — Update screenshots_dir description to reference new tool name
  • tests/test_panel_mcp.py — Update tests for renamed tool and add coverage for console log capture, log level filtering, and the error case
  • docs/explanation/tools.md — Replace panel_take_screenshot section with panel_inspect_app documentation

Test plan

  • pixi run test — all existing and new tests pass
  • pixi run pre-commit-run — linting, formatting, and type checks pass
  • pixi run mkdocs build --strict — docs build without warnings
  • Manually verify panel_inspect_app returns both screenshot and console logs against a running Panel app
  • Verify log_level filtering returns only matching entries
  • Verify screenshot=False returns only console logs (no image)
  • Verify console_logs=False returns only the screenshot (no text)
  • Verify screenshot=False, console_logs=False raises ValueError

Copilot AI and others added 6 commits February 9, 2026 12:00
Co-authored-by: MarcSkovMadsen <42288570+MarcSkovMadsen@users.noreply.github.com>
…eenshot parameter

Co-authored-by: MarcSkovMadsen <42288570+MarcSkovMadsen@users.noreply.github.com>
Co-authored-by: MarcSkovMadsen <42288570+MarcSkovMadsen@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 19, 2026 18:31
@MarcSkovMadsen MarcSkovMadsen merged commit b098ce4 into main Feb 19, 2026
7 of 13 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the Panel MCP server's screenshot tool by renaming it to panel_inspect_app and extending it to capture both screenshots and browser console logs in a single operation, making it easier to debug JavaScript errors in Panel apps (especially custom components). Additionally, it adds two new Panel extension repositories (panel-live and panel-reactflow) to the built-in documentation repositories.

Changes:

  • Renamed panel_take_screenshot to panel_inspect_app with enhanced functionality to capture both screenshots and browser console logs
  • Added support for filtering console logs by level (error, warning, log, etc.) and saving screenshots to disk with configurable paths
  • Added panel-live and panel-reactflow as built-in documentation repositories in the configuration

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/holoviz_mcp/panel_mcp/server.py Renamed tool from take_screenshot to inspect_app, added console log capture via Playwright event handlers, and implemented screenshot saving with configurable paths
src/holoviz_mcp/panel_mcp/models.py Added ConsoleLogEntry Pydantic model to represent browser console log entries with level, message, and timestamp fields
src/holoviz_mcp/config/models.py Added screenshots_dir field to ServerConfig for configuring the default screenshot save location
src/holoviz_mcp/config/config.yaml Added panel-live and panel-reactflow repository configurations following the same pattern as other HoloViz documentation repositories
tests/test_panel_mcp.py Updated test suite with comprehensive coverage for the renamed tool including tests for screenshot-only, logs-only, log filtering, error handling, and screenshot saving functionality
docs/explanation/tools.md Updated documentation to reflect the new tool name, parameters, and use cases with detailed examples
CLAUDE.md Added file containing reference to AGENTS.md (not mentioned in PR description)

Comment thread tests/test_panel_mcp.py
Comment on lines +369 to +373
import holoviz_mcp.panel_mcp.server as _srv

if _srv._playwright_manager is not None:
await _srv._playwright_manager.close()
_srv._playwright_manager = None

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import statement import holoviz_mcp.panel_mcp.server as _srv should be placed at the beginning of the test function before resetting the PlaywrightManager, for consistency with other test functions that follow this pattern (see test_inspect_app_screenshot_only, test_inspect_app_console_logs_only, test_inspect_app_log_level_filter). This ensures the module is imported before attempting to access its attributes.

Copilot uses AI. Check for mistakes.
Comment thread tests/test_panel_mcp.py
Comment on lines +391 to +395
import holoviz_mcp.panel_mcp.server as _srv

if _srv._playwright_manager is not None:
await _srv._playwright_manager.close()
_srv._playwright_manager = None

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import statement import holoviz_mcp.panel_mcp.server as _srv should be placed at the beginning of the test function before resetting the PlaywrightManager, for consistency with other test functions that follow this pattern (see test_inspect_app_screenshot_only, test_inspect_app_console_logs_only, test_inspect_app_log_level_filter). This ensures the module is imported before attempting to access its attributes.

Copilot uses AI. Check for mistakes.
Comment thread tests/test_panel_mcp.py
Comment on lines +413 to +417
import holoviz_mcp.panel_mcp.server as _srv

image_content = result.content[0]
if _srv._playwright_manager is not None:
await _srv._playwright_manager.close()
_srv._playwright_manager = None

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import statement import holoviz_mcp.panel_mcp.server as _srv should be placed at the beginning of the test function before resetting the PlaywrightManager, for consistency with other test functions that follow this pattern (see test_inspect_app_screenshot_only, test_inspect_app_console_logs_only, test_inspect_app_log_level_filter). This ensures the module is imported before attempting to access its attributes.

Copilot uses AI. Check for mistakes.
Comment thread CLAUDE.md
@@ -0,0 +1 @@
@AGENTS.md

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CLAUDE.md file addition is not mentioned in the PR description or test plan, and appears unrelated to the "Enhancement/browser tools" changes. If this file is intentional, consider adding it in a separate PR with appropriate documentation explaining its purpose. If it's accidental, it should be removed from this PR.

Copilot uses AI. Check for mistakes.
Comment thread tests/test_panel_mcp.py
Comment on lines +427 to 429
await client.call_tool("inspect_app", {"url": "data:text/html,<html></html>", "screenshot": False, "console_logs": False})
assert "at least one" in str(exc_info.value).lower()

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing PlaywrightManager cleanup after test execution. This test should follow the same cleanup pattern as other Playwright tests to prevent cross-test browser leaks. Add cleanup code in a finally block or after the assertion, similar to test_inspect_app_rejects_relative_path.

Suggested change
await client.call_tool("inspect_app", {"url": "data:text/html,<html></html>", "screenshot": False, "console_logs": False})
assert "at least one" in str(exc_info.value).lower()
await client.call_tool(
"inspect_app",
{"url": "data:text/html,<html></html>", "screenshot": False, "console_logs": False},
)
assert "at least one" in str(exc_info.value).lower()
import holoviz_mcp.panel_mcp.server as _srv
if _srv._playwright_manager is not None:
await _srv._playwright_manager.close()
_srv._playwright_manager = None

Copilot uses AI. Check for mistakes.
@@ -499,38 +505,129 @@ def _get_playwright_manager() -> PlaywrightManager:


@mcp.tool()

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tool decorator should use @mcp.tool without parentheses for consistency with other tools in the codebase (list_packages, search_components, list_components, get_component, get_component_parameters). Only use @mcp.tool() with parentheses when passing arguments like enabled=False.

Suggested change
@mcp.tool()
@mcp.tool

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants